package com.winona.code;

import java.util.HashMap;

import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

import com.taplinker.client.AppConfigFactory;
import com.taplinker.core.rpc.Result;
import com.taplinker.core.rpc.command.SimpleBaseCommand;
import com.taplinker.core.rpc.http.HttpTemplate;
import com.winona.ConstantValue;

public class ReserveCmd extends SimpleBaseCommand {

	private String phonenum;
	private String email;

	private Handler mHandler;
	private long id = AppConfigFactory.getInstance().getExpert().getId();

	public ReserveCmd(Context ctx, String phonenum, String email,
			Handler mHandler, long id) {
		super(ctx);
		this.phonenum = phonenum;
		this.email = email;
		this.mHandler = mHandler;
		this.id = id;
	}

	@Override
	public Result go() {

		HashMap<String, String> params = new HashMap<String, String>();
		params.put("phonenum", phonenum);
		params.put("email", email);
		params.put("id", String.valueOf(id));
		params.put("type", "EXPERT");
		params.put("activity_id", String.valueOf(id));
		return new HttpTemplate().postForForm(ConstantValue.COMMON
				+ "/academic/activity/order", params);
	}

	@Override
	public void yes(Result result) {
		int position = 1;
		mHandler.sendEmptyMessage(position);
		Toast.makeText(context, "预约成功", Toast.LENGTH_SHORT).show();

	}

	@Override
	public void no(Result result) {
		Toast.makeText(context, "预约失败", Toast.LENGTH_SHORT).show();
	}

}
